#!/bin/sh
region=$1
thisdir="$(dirname $0)"	
if [ -z "$region" ]; then
    region="westus"
fi

key=$2
if [ -n "$key" ]; then
    key="--authoringKey $key"
fi
 
bf luis:build --luConfig $thisdir/luconfig.json --region=$region $key --out $thisdir/generated --log
 
res=$?
if [ $res != 0 ]; then
    echo "build [region] [LUISAuthoringKey]"
    echo "Region defaults to westus."
    echo "Set LUISAuthoringKey default with bf config:set:luis --authoringKey=<yourKey>"
fi
exit $res
